<%
# Issue Extensions plugin for Redmine
# Copyright (C) 2010-2011  Takashi Takebayashi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-%><%
if IssueExtensionsUtil.is_enabled?(project) -%><%
  parameters = request.parameters %>
<hr />
<div id="issue_extensions_form">
  <strong><%= l(:issue_extensions) %></strong><br />
  <%= hidden_field_tag :relation_issue_id, parameters[:relation_issue] %>
  <%= submit_tag l(:button_assigned_to_oneself), {:type => 'button', :onClick => 'selectOneself()'} %>
  <script type="text/javascript">
    function selectOneself() {
      // プルダウンオブジェクトを取得する
      var options = document.getElementById('issue_assigned_to_id');
      var oneself_value = '<%= User.current.id %>'
      for (var i = 0; i < options.length; i++){
        var options_value = options[i].value;
        if (oneself_value == options_value) {
          options.selectedIndex = i;
          break;
        }
      }
    }
    function onload_duplicate_issue() {
      var get = new Array();
      /* duplicate_issue要素検索 */
      if (location.search.length > 1) {
        var strings = location.search;
        var requests = strings.substr(1).split("&");
        for (var i = 0; i < requests.length; i++) {
          var r = requests[i].split("=");
          get[r[0]] = r[1];
        }
        if (get['duplicate_issue']){
          /* 値クリア */
          document.getElementById("issue_status_id").selectedIndex = 0;
          document.getElementById("issue_start_date").value = "";
          document.getElementById("issue_due_date").value = "";
          document.getElementById("issue_done_ratio").selectedIndex = 0;
        }
      }
    }
    window.onload = onload_duplicate_issue();
  </script>
</div><%
end %>
